package com.ml.springboot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ml.springboot.mapper.LeaveTypeMapper;
import com.ml.springboot.pojo.LeaveType;
import com.ml.springboot.pojo.VO.BlogCountVO;
import com.ml.springboot.pojo.VO.LeaveTypeVO;
import com.ml.springboot.pojo.query.BlogTypeQuery;
import com.ml.springboot.service.ILeaveTypeService;
import com.ml.springboot.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeaveTypeServiceImpl implements ILeaveTypeService {
    @Autowired
    private LeaveTypeMapper blogTypeMapper;
    @Override
    public PageResult list(BlogTypeQuery blogTypeQuery) {
        PageHelper.startPage(blogTypeQuery.getPage(), blogTypeQuery.getLimit());
        //当前分页数据
        List<LeaveType> list = blogTypeMapper.list(blogTypeQuery);
        PageInfo<LeaveType> pageInfo = new PageInfo<>(list);
        int totalCount = (int) pageInfo.getTotal();
        return new PageResult(0,"",totalCount,list);
    }

    @Override
    public void deletedById(Integer id) {
        blogTypeMapper.deleteById(id);
    }

    @Override
    public void deleteAll(Integer[] ids) {
        for (Integer id : ids) {
            blogTypeMapper.deleteById(id);
        }
    }

    @Override
    public void add(LeaveType blogType) {
        blogTypeMapper.add(blogType);
    }

    @Override
    public LeaveType selectById(Integer id) {
        return blogTypeMapper.selectById(id);
    }

    @Override
    public void update(LeaveType blogType) {
        blogTypeMapper.update(blogType);
    }

    @Override
    public List<LeaveTypeVO> selectAll() {
        return blogTypeMapper.selectAll();
    }

    @Override
    public List<BlogCountVO> blogCount() {
        return blogTypeMapper.blogCount();
    }


}
